<!DOCTYPE html>
<html lang="zh-CN">
    
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>
            注册
        </title>
        <meta content="光大好车" name="keywords" />
        <meta content="光大好车" name="description" />
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="iconfont/iconfont.css">
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <!--[if lt IE 9]>
            <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js">
            </script>
            <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js">
            </script>
        <![endif]-->
        <script type="text/javascript" src="script/jquery.js"></script>
        <script type="text/javascript" src="script/bootstrap.min.js"></script>
        <script type="text/javascript" src="script/Validform_v5.3.2_min.js"></script>
        <script src="script/uploadimage.js"></script>
        <script type="text/javascript" src="script/jquery.js"></script> 
        <style>
            #drop_area{
                margin:0 auto;
                width:30px;
                height:30px;
            }
            .image{
                margin-left:10%;
            }
        </style>
        
    </head>
    
    <body>
        <div id="brand-box">
            <header class="mo-header">
                <div class="mo-header-left">
                    <a href="#">
                        首页
                    </a>
                    <i class="iconfont">
                        &#xe61d;
                    </i>
                    <a href="#">
                        注册
                    </a>
                </div>
            </header>
        </div>
        <!--内容-->
        <div class="container mt20">
            <div class="login_main">
                <div class="mt20">
                    <form name="loginform" class="form-horizontal" method="post" action="#">
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <div id="regnotice" class="lognotice">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <input type="text" name="telephone" class="form-control" placeholder="请输入手机号"
                                datatype="m" sucmsg="手机号验证通过！" nullmsg="请输入手机号！" errormsg="请输入正确的手机号！"
                                />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <input type="text" name="password" class="form-control" placeholder="请输入密码"  nullmsg="请输入密码！"/>
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <div class="col-xs-5 col-xs-offset-1">
                                <input type="text" placeholder="请输入验证码" class="form-control" name="authcode"
                                nullmsg="请输入验证码！" errormsg="请输入正确的验证码！" />
                            </div>
                            <div class="col-xs-5">
                                <input type="button" value="获取验证码" class="btn btn-default btn-block sendAuthCode" id="sendmsg">
                            </div>
                        </div>-->
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <input type="text" placeholder="请输入昵称" name="nickname" class="form-control" datatype="*6-20" nullmsg="请输入昵称！" />
                            </div>
                        </div>
						<!--<div>
                            <label class="image">请上传头像</label>
                            <div id="drop_area"></div>
                            <img src="" class="img" style="display:none"/>
						</div>-->
						<div class="release_up_pic">
							<div class="up_pic">
								<div id="chose_pic_btn" class="col-md-1 col-xs-4">
									<img src="images/true.jpg" id="addnew" style="margin-left:100%">
								</div>
							</div>
						</div>
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <input type="button" value="注 册" class="btn btn-danger btn-block" id="register">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-10 col-xs-offset-1">
                                <a href="#" target="_blank" class="btn btn-default btn-block" id="login">
                                    我要登录
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!--内容-->
        <!--<a href="javascript:;" id="returntop">-->
        </a>
        <script type="text/javascript" src="script/jquery.lazyload.js">
        </script>
        <script type="text/javascript" charset="utf-8">
            $(function() {
                $("img.lazy").lazyload({
                    effect: "fadeIn"
                });
               /* $('#returntop').click(function() {
                    $('html,body').animate({
                        scrollTop: '0px'
                    },
                    1000);
                    return false;
                });*/
            });
        </script>

        <script type="text/javascript">
            var dragImgUpload = new DragImgUpload("#drop_area",{
                callback:function (files) {
                    //回调函数，可以传递给后台等等
                    console.log(files);
                    $(".img").attr('src',files); 
                }
            })
        </script>
        <script>
            $(function(){  
                //发送验证码
                $(".sendAuthCode").on("click", function(){
                    var telephone = $("input[name=telephone]").val();
                    $.ajax({
                        url: "http://localhost:8080/app/users/shcUser/sendAuthCode",
                        //async : true,
                        type: "post",
                        dataType: "json",
                        data: {"telephone":telephone},
                        success: function (data) {
                            if(data == 'fail'){
                                alert("发送验证码失败");
                                return ;
                            }
                        }
                    });
                }) 
                //提交
                $(".sub-btn").on("click", function(){
                    var data = {};
                    data.telephone = $.trim($("input[name=telephone]").val());
                    data.authcode = $.trim($("input[name=authcode]").val());
                    data.nickname = $.trim($("input[name=nickname]").val());
                    data.image = $.trim($(".img").val());
                    $.ajax({
                        url: "http://localhost:8080/app/users/shcUser/register",
                       // async : true,
                        type: "post",
                        dataType: "json",
                        data: data,
                        success: function (data) {
                            if(data == 'fail'){
                                alert("注册失败");
                                return ;
                            }
                            alert("注册成功");
                        }
                    });
                })
            });
        </script>

        <script>
            $("#register").on("click", function(){
                $.ajax({
                    url: "http://122.14.200.206:8080/sechandcar/app/users/shcUser/register",
                    //async : true,
                    type: "post",
                    //dataType: "json",
                    data: {
                        "telephone":$.trim($("input[name=telephone]").val()),
						"password":$.trim($("input[name=password]").val()),
						"nickname": $.trim($("input[name=nickname]").val()),                                         
						"image":$.trim($('.img').attr('src'))
				    },
                    success: function (data) {
                        if(data == 'success'){
                            alert("注册成功");
                            window.location.href='http://122.14.200.206:8080/ershouche/login.html';
                            return;
                        }else{
                            alert("注册失败");
                        }
                    },
                    error: function (XMLHttpResponse, textStatus, errorThrown) { 
                        alert("1 异步调用返回失败,XMLHttpResponse.readyState:"+XMLHttpResponse.readyState); 
                        alert("2 异步调用返回失败,XMLHttpResponse.status:"+XMLHttpResponse.status); 
                        alert("3 异步调用返回失败,textStatus:"+textStatus); 
                        alert("4 异步调用返回失败,errorThrown:"+errorThrown); 
                    }
                });
            });
        </script>
        <script>
            $("#login").on("click", function(){
              //alert($(".telephone").val());
              $.ajax({
                type:"post",
                url:"http://122.14.200.206:8080/sechandcar/app/users/shcUser/loginpage",
                //async:false,
                data: {},
                datatype:'json',
                success:function(data){		
                 // window.alert(data);
                  if(data == 'success'){
                    //alert(1);
                    window.location.href='login.html';
                  } 
                },
                error:function(data){
                  //console.log(data);
                  //window.alert(data);
                }
              });	
            });
        </script>
    </body>

</html>